var names=$.cookie("username")?JSON.parse($.cookie("username")):[];
var typesid=location.search.split('=')[1];
let str='';
if($.cookie("username")){
  huanying=`<div class="dc fl">欢迎${names}</div>`;
  $('.fr .dc').html(huanying);
}      
console.log(typesid);
$.get('../html/getGoodsList.php',{typeId:typesid},function(data){
  console.log(data);
    var res = JSON.parse(data)
    console.log(res);
    res.forEach(item=>{
     str+= `<div class="shop"  onclick='location.href="./商品详情页.html?goodsid=${item.goodsId}"'>
      <div class="img">
          <img src="${item.goodsImg}" alt="">
      </div>
      <div class="creat">
          <p>${item.goodsName}</p>
          <p class="p1">
              <span>￥</span>
              <span>${item.goodsPrice}</span>
              <span>起</span>
          </p>
      </div>
  </div>`;

    });
      
    $('.list .container .listmap').html(str)});

  //   function ajax(method, url) {
  //       return new Promise(function (resolve, reject) {
  //      //借用jquery发请求
  //      $.ajax(url, {
  //        type: method,
  //        data: {typeid:001 }, //携带并发给服务器的参数
  //        success: function (res) {
  //          resolve(res);
  //        },
  //        error: function (res) {
  //          reject(res);
  //        },
  //      });
  //    });
  let leibie='';
$.get('../html/getGoodsType.php',function(data){
    var fenleichuangcao=JSON.parse(data);

    fenleichuangcao.forEach(item=>{
        leibie+=`<div class="chuangzao" onclick='location.href="./商品栏界面.html?typesid=${item.typeId}"'>${item.goodsType}</div>`
    })
    $('.fenleishangpin').html(leibie);
    
    console.log(data);
    console.log(leibie);
})
